/*
 * @Author: xyf
 * @Date: 2021-06-22 18:45:22
 * @LastEditTime: 2021-07-27 09:45:33
 * @LastEditors: xyf
 * @Description: 配置文件
 */
const path = require('path')
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'element-plus',
          esModule: true,
          ensureStyleFile: true,
          resolveStyle: (name) => {
            name = name.slice(3)
            return `element-plus/packages/theme-chalk/src/${name}.scss`
          },
          resolveComponent: (name) => {
            return `element-plus/lib/${name}`
          }
        }
      ]
    })
  ],
  server: {
    host: 'localhost',
    port: 8001,
    open: true
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }

  // css: {
  //   preprocessorOptions: {
  //     scss: {
  //       additionalData: '@import "src/assets/styles/index.scss";'
  //     }
  //   }
  // }
})
